/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojos;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
/**
 *
 * @author A7med Kotb
 */
@Entity
@Table(name = "time_log")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Reports.findAll", query = "SELECT t FROM TimeLog t where t.tlId= :tlId"),
    @NamedQuery(name = "Reports.findByTlId", query = "SELECT t FROM TimeLog t WHERE t.tlId = :tlId"),
    @NamedQuery(name = "Reports.findByTask", query = "SELECT t FROM TimeLog t WHERE t.task = :task"),
    @NamedQuery(name = "Reports.findByActivity", query = "SELECT t FROM TimeLog t WHERE t.activity = :activity"),
    @NamedQuery(name = "Reports.findByWorkedHours", query = "SELECT t FROM TimeLog t WHERE t.workedHours = :workedHours"),
    @NamedQuery(name = "Reports.findProjects", query = "SELECT t FROM TimeLog t WHERE t.emplyee = :emplyee and t.status !='submitted'"),
    @NamedQuery(name = "Reports.findByDate", query = "SELECT t FROM TimeLog t WHERE t.date = :date"),
    @NamedQuery(name = "Reports.findByCreatedAt", query = "SELECT t FROM TimeLog t WHERE t.createdAt = :createdAt"),
    @NamedQuery(name = "Reports.delete", query = "delete from TimeLog where tlId= :tlId"),
    @NamedQuery(name = "Reports.update", query = "update TimeLog set status='saved' where tlId= :tlId"),
    @NamedQuery(name = "Reports.findByStatus", query = "SELECT t FROM TimeLog t WHERE t.status = :status"),
    @NamedQuery(name = "Reports.findByProjectandDate", query = "SELECT t FROM TimeLog t WHERE t.project = :project and t.status = 'submitted' and t.date = :startDate"),
    @NamedQuery(name = "Reports.findByEmployeeandDate", query = "SELECT t FROM TimeLog t WHERE t.emplyee = :empID and t.status = 'submitted' and t.date = :startDate")})
public class Reports implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
   
    @Column(name = "tl_id")
    private Integer tlId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "task")
    private String task;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "activity")
    private String activity;
    @Basic(optional = false)
    @NotNull
    @Column(name = "worked_hours")
    private int workedHours;
    @Basic(optional = false)
    @NotNull
    @Column(name = "date")
    @Temporal(TemporalType.DATE)
    private Date date;
    @Column(name = "created_at")
    private String createdAt;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "status")
    private String status;
    @JoinColumn(name = "project", referencedColumnName = "pro_id")
    @ManyToOne(optional = false)
    private Projects project;
    @JoinColumn(name = "emplyee", referencedColumnName = "emp_id")
    @ManyToOne(optional = false)
    private Employees emplyee;
    @JoinColumn(name = "created_by", referencedColumnName = "emp_id")
    @ManyToOne(optional = false)
    private Employees createdBy;


    public Reports() {
    }

    public Reports(Integer tlId) {
        this.tlId = tlId;
    }

    public Reports(Integer tlId, String task, String activity, int workedHours, Date date, String createdAt, String status) {
        this.tlId = tlId;
        this.task = task;
        this.activity = activity;
        this.workedHours = workedHours;
        this.date = date;
        this.createdAt = createdAt;
        this.status = status;
    }

    public Integer getTlId() {
        return tlId;
    }

    public void setTlId(Integer tlId) {
        this.tlId = tlId;
    }

    public String getTask() {
        return task;
    }

    public void setTask(String task) {
        this.task = task;
    }

    public String getActivity() {
        return activity;
    }

    public void setActivity(String activity) {
        this.activity = activity;
    }

    public int getWorkedHours() {
        return workedHours;
    }

    public void setWorkedHours(int workedHours) {
        this.workedHours = workedHours;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Projects getProject() {
        return project;
    }

    public void setProject(Projects project) {
        this.project = project;
    }

    public Employees getEmplyee() {
        return emplyee;
    }

    public void setEmplyee(Employees emplyee) {
        this.emplyee = emplyee;
    }

    public Employees getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Employees createdBy) {
        this.createdBy = createdBy;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tlId != null ? tlId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reports)) {
            return false;
        }
        Reports other = (Reports) object;
        if ((this.tlId == null && other.tlId != null) || (this.tlId != null && !this.tlId.equals(other.tlId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojos.Reports[ tlId=" + tlId + " ]";
    }
   
}
